package cn.crm.system.service.impl;

import cn.crm.common.annotation.DataScope;
import cn.crm.common.utils.SecurityUtils;
import cn.crm.system.domain.pojo.dto.BusinessDto;
import cn.crm.system.domain.pojo.dto.ContactsDto;
import cn.crm.system.domain.pojo.dto.OfferDto;
import cn.crm.system.domain.pojo.entity.Business;
import cn.crm.system.domain.pojo.vo.*;
import cn.crm.system.mapper.*;
import cn.crm.system.service.IBusinessService;
import cn.crm.system.service.IOfferService;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


/**
 * 处理报价明显的接口
 */

@Slf4j
@Service
public class OfferServiceImpl implements IOfferService {

    @Autowired
    private OfferMapper offerMapper;
    @Autowired
    private QuotedPricebuildMapper quotedPricebuildMapper;
    @Autowired
    private  PricePdfMapper pricePdfMapper;


//查询报价明细
    @Override
    public List<OfferVo> selectOfferVoListAndcast(OfferDto offerDto) {
        //开始查询报价明细
        List<OfferVo> offerVos = offerMapper.selectOfferVoListAndcast(offerDto);
        return offerVos;
    }

    //删除报价明细
    @Override
    public int deloffer(Long[] id) {
        //报价单表头以及删除开始删除表身和url
        int deloffer = offerMapper.deloffer(id);
        //开始删除表身
        int delquotedPricebuild = quotedPricebuildMapper.delquotedPricebuild(id);
        //开始删除url
        int i = pricePdfMapper.delPDF(id);
        return deloffer+delquotedPricebuild+i;
    }
    //通过id查询pdf
    @Override
    public List<PricePdfVo> selectpdfListAndcast(Long id) {
        List<PricePdfVo> pricePdfVos = pricePdfMapper.selectpdfListAndcast(id);
        return pricePdfVos;
    }

    @Override
    public List<OfferVo> selectOfferVoListAndcastById(Long seriesId) {
        //开始查询报价明细
        List<OfferVo> offerVos = offerMapper.selectOfferVoListAndcastById(seriesId);
        return offerVos;

    }
}
